home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Champak 66
/
Vol 66.iso
/
games
/
bob_espo.swf
/
scripts
/
__Packages
/
MiniGames
/
BTW
/
BreakTheWallMG.as
next >
Wrap
Text File
|
2013-04-24
|
4KB
|
122 lines
class MiniGames.BTW.BreakTheWallMG extends MiniGames.BaseMiniGame
{
static var sSTATE_NORMAL = "Normal";
static var sSTATE_WHACKY = "Whacky";
static var nMAX_TIME = 15;
static var nSECOND_VALUE = 100;
function BreakTheWallMG(_mcRef)
{
super(_mcRef);
this.showInstructions();
}
function initMiniGame()
{
this.aBalls = new Array();
this.oSpongeBob = new MiniGames.BTW.BTWSpongeBob(this.mcRef.mcState.mcBob,this);
this.oWallPart1 = new MiniGames.BTW.BTWWallPart(this.mcRef.mcState.mcPart1,this);
this.oWallPart2 = new MiniGames.BTW.BTWWallPart(this.mcRef.mcState.mcPart2,this);
this.oWallPart3 = new MiniGames.BTW.BTWWallPart(this.mcRef.mcState.mcPart3,this);
this.oWallPart4 = new MiniGames.BTW.BTWWallPart(this.mcRef.mcState.mcPart4,this);
this.oWallPart5 = new MiniGames.BTW.BTWWallPart(this.mcRef.mcState.mcPart5,this);
this.oWallPart6 = new MiniGames.BTW.BTWWallPart(this.mcRef.mcState.mcPart6,this);
}
function destroyMiniGame()
{
super.destroyMiniGame();
this.oWallPart1.cleanUp();
this.oWallPart2.cleanUp();
this.oWallPart3.cleanUp();
this.oWallPart4.cleanUp();
this.oWallPart5.cleanUp();
this.oWallPart6.cleanUp();
this.oSpongeBob.cleanUp();
for(var i in this.aBalls)
{
this.aBalls[i].cleanUp();
}
}
function calculateScore()
{
this.addScoreFromTimeLeft(MiniGames.BTW.BreakTheWallMG.nMAX_TIME,MiniGames.BTW.BreakTheWallMG.nSECOND_VALUE);
}
function validateEndMiniGame()
{
if(this.oWallPart1.isDestroyed() && (this.oWallPart2.isDestroyed() && (this.oWallPart3.isDestroyed() && (this.oWallPart4.isDestroyed() && (this.oWallPart5.isDestroyed() && this.oWallPart6.isDestroyed())))))
{
this.setVictory();
}
}
function setState(_sState)
{
super.setState(_sState);
if(this.sState == MiniGames.BaseMiniGame.sSTATE_MINIGAME || this.sState == MiniGames.BaseMiniGame.sSTATE_VICTORY)
{
if(Main.getRef().isCheatClothesActivated())
{
this.mcRef.mcState.gotoAndStop(MiniGames.BTW.BreakTheWallMG.sSTATE_WHACKY);
}
else
{
this.mcRef.mcState.gotoAndStop(MiniGames.BTW.BreakTheWallMG.sSTATE_NORMAL);
}
}
else if(Main.getRef().isCheatClothesActivated())
{
this.mcRef.mcBack.gotoAndStop(MiniGames.BTW.BreakTheWallMG.sSTATE_WHACKY);
}
else
{
this.mcRef.mcBack.gotoAndStop(MiniGames.BTW.BreakTheWallMG.sSTATE_NORMAL);
}
}
function doUnPause()
{
super.doUnPause();
this.mcRef.stop();
this.mcRef.mcBack.stop();
if(this.sState == MiniGames.BaseMiniGame.sSTATE_MINIGAME || this.sState == MiniGames.BaseMiniGame.sSTATE_VICTORY)
{
this.mcRef.mcState.stop();
}
}
function clickOnWall(_oSrc)
{
this.oSpongeBob.throwABall(_oSrc);
}
function createBall(_oAimWall, _nX, _nY)
{
this.aBalls.push(new MiniGames.BTW.BTWBall(this.mcRef.mcState,_oAimWall,_nX,_nY));
}
function MiniGame()
{
super.MiniGame();
var _loc3_ = this.aBalls.length - 1;
while(_loc3_ >= 0)
{
if(this.aBalls[_loc3_].isExploding())
{
this.aBalls[_loc3_].Target.damage();
}
else if(this.aBalls[_loc3_].isDestroyed())
{
this.aBalls[_loc3_].cleanUp();
delete this.aBalls[_loc3_];
this.aBalls.splice(_loc3_,1);
}
_loc3_ = _loc3_ - 1;
}
if(this.oWallPart1.isDestroyed() && (this.oWallPart3.isDestroyed() && this.oWallPart5.isDestroyed()))
{
this.mcRef.mcState.mcShadowLeft._visible = false;
}
if(this.oWallPart2.isDestroyed() && (this.oWallPart4.isDestroyed() && this.oWallPart6.isDestroyed()))
{
this.mcRef.mcState.mcShadowRight._visible = false;
}
}
function Victory()
{
this.bOver = true;
}
}